import Vue from "vue";
import Router from "vue-router";  // 从vueRouter依赖中引入

const Home = () => import('../views/Home/Home.vue');
const Content = () => import('../views/Content/Content.vue');
const ContentPan = () => import('../views/Content/ContentPan/ContentPan.vue');
const ContentShare = () => import('../views/Content/ContentShare/ContentShare.vue');
const ContentAllFiles = () => import('../views/Content/ContentPan/AllFiles.vue');
const ContentPicture = () => import('../views/Content/ContentPan/Picture.vue');
const ContentDocument = () => import('../views/Content/ContentPan/Document.vue');
const ContentVideo = () => import('../views/Content/ContentPan/Video.vue');
const ContentSeed = () => import('../views/Content/ContentPan/Seed.vue');
const ContentAudio = () => import('../views/Content/ContentPan/Audio.vue');
const ContentOther = () => import('../views/Content/ContentPan/Other.vue');
const ContentNoUse = () => import('../views/Content/ContentPan/NoUse.vue');

Vue.use(Router);

const router = new Router({
  mode: 'hash',
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      meta: { label: '登录页' },
    },
    {
      path: '/content',
      name: 'content',
      component: Content,
      meta: { label: '主页' },
      children: [
        {
          path: 'pan',
          name: 'content-pan',
          component: ContentPan,
          meta: { label: '网盘' },
          children: [
            {
              path: 'all-files',
              name: 'allFiles',
              component: ContentAllFiles,
              meta: { label: '全部文件' },
            },
            {
              path: 'picture',
              name: 'picture',
              component: ContentPicture,
              meta: { label: '图片' },
            },
            {
              path: 'document',
              name: 'document',
              component: ContentDocument,
              meta: { label: '文档' },
            },
            {
              path: 'video',
              name: 'video',
              component: ContentVideo,
              meta: { label: '视频' },
            },
            {
              path: 'seed',
              name: 'seed',
              component: ContentSeed,
              meta: { label: '种子' },
            },
            {
              path: 'audio',
              name: 'audio',
              component: ContentAudio,
              meta: { label: '音乐' },
            },
            {
              path: 'other',
              name: 'other',
              component: ContentOther,
              meta: { label: '其他' },
            },
            {
              path: 'no-use',
              name: 'noUse',
              component: ContentNoUse,
              meta: { label: '暂无功能' },
            },
          ]
        },
        {
          path: 'share',
          name: 'content-share',
          component: ContentShare,
          meta: { label: '分享' },
        }
      ]
    }
  ],
})

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router;